package router

import (
	"Software/controller"
	_ "Software/docs"
	"Software/middleware"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func Init() {
	r := gin.Default()
	r.Use(middleware.AccessLog())
	s := r.Group("software")
	{
		s.POST("createSoftware", controller.CreateSoftware).Use(middleware.AuthMiddleware())
		s.GET("findSoftwareList", controller.FindSoftwareList)
		s.POST("findDetailedSoftware", controller.FindDetailedSoftware)
		s.POST("downloadSoftware", controller.DownloadSoftware)
	}
	f := r.Group("feedback")
	{
		f.GET("findFeedBackList", controller.FindFeedBackList).Use(middleware.AuthMiddleware())
		f.POST("addFeedBack", controller.AddFeedBack)
		f.POST("auditFeedBack", controller.AuditFeedBack).Use(middleware.AuthMiddleware())
	}
	auditor := r.Group("auditor")
	{
		auditor.GET("beginRegister", controller.BeginRegister)
		auditor.POST("finishRegister", controller.FinishRegister)
		auditor.GET("beginLogin", controller.BeginLogin)
		auditor.POST("finishLogin", controller.FinishLogin)
	}

	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
	r.Run(":8080")
}
